import {Component} from '@angular/core';
import {NavController, NavParams, Config} from 'ionic-angular';
import {SubPage} from "../../common/subPage";
import {BindIdcardPage} from "../bind-idcard/bind-idcard";
import {BankCardPage} from "../bank-card/bank-card";
// import {ControlsCheck} from "../../common/controlsCheck";
// import {FormBuilder, FormGroup, Validators} from "@angular/forms";
// import {CONST} from "../../common/const";
import {UserProvider} from "../../providers/user/user";

@Component({
  selector: 'page-auth-bind',
  templateUrl: 'auth-bind.html',
})
export class AuthBindPage extends SubPage {

  bindIdcardPage: any
  bankCardPage: any
  status: any = {
    idcard: false,
    bank: false,
  }

  constructor(public navCtrl: NavController,
              config: Config,
              private userProvider: UserProvider,
              public navParams: NavParams) {
    super(config)
    this.bindIdcardPage = BindIdcardPage
    this.bankCardPage = BankCardPage
  }

  getAuthStatus(){
    this.userProvider.getAuthStatus({
      success:(d)=>{
        this.status.idcard = d.authName == '10'
        this.status.bank = d.authBankcard == '10'
      }
    })
  }

  gotoPage(key,check){
    const config = {
      idcard: BindIdcardPage
    }
    if(check && this.status[key]){
      return
    }
    this.navCtrl.push(config[key])
  }

  viewWillEnter(){
    this.getAuthStatus()
  }

}
